#include<bits/stdc++.h>
using namespace std;
vector<string> name;

const int N = 1e6 + 10;
int m, n;
string str;
string a[N];
int f[N], pre[N];
int q[N];

int main() {
    memset(pre, -1, sizeof(pre));
    cin >> str;
    m = str.size();
    for (int i = 0; i < m; ) {
        int j = i + 1;
        while (j < m && 'a' <= str[j] && str[j] <= 'z') ++j;
        a[++n] = str.substr(i, j - i);
        i = j;
    }
    m = 0;
    for (int i = 1; i <= n; i++) {
        f[i] = 1;
        int l = 0, r = m;
        while (l < r) {
            int mid = (l + r + 1 ) >> 1;
            if (a[q[mid]] < a[i]) l = mid;
            else r = mid - 1;
        }
        f[i] = r + 1;
        m = max(m, r + 1);
        pre[i] = q[r];
        q[r + 1] = i;
    }
    vector<string> res;
    for (int i = q[m]; i; i = pre[i]) res.push_back(a[i]);
    for (int i = res.size() - 1; i >= 0; --i) cout << res[i];
    cout <<endl;
    return 0;
}